package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.wms.dto.ProcessDto;
import com.ruoyi.wms.dto.StockProductDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.wms.domain.StockProduct;
import com.ruoyi.wms.service.IStockProductService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 库存商品信息Controller
 *
 * @author ruoyi
 * @date 2025-10-24
 */
@Api(value = "拆解物库存商品信息stockProduct", tags = "拆解物库存商品信息库存商品信息表,不是报废车已经是零件Controller")
@RestController
@RequestMapping("/stockProduct")
public class StockProductController extends BaseController {
    @Autowired
    private IStockProductService stockProductService;

    /**
     * 查询库存商品信息列表
     */
    @RequiresPermissions("wms:product:list")
    @GetMapping("/list")
    public TableDataInfo list(StockProductDto stockProduct) {
        startPage();
        List<StockProduct> list = stockProductService.selectStockProductList(stockProduct);
        return getDataTable(list);
    }



    /**
     * 获取库存商品信息详细信息
     */
    @RequiresPermissions("wms:product:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(stockProductService.selectStockProductById(id));
    }


    /**
     * 修改库存商品信息
     */
    @RequiresPermissions("wms:product:edit")
    @Log(title = "库存商品信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockProduct stockProduct) {
        return toAjax(stockProductService.updateStockProduct(stockProduct));
    }

    /**
     * 删除库存商品信息
     */
    @RequiresPermissions("wms:product:remove")
    @Log(title = "库存商品信息", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        return toAjax(stockProductService.deleteStockProductByIds(ids));
    }


    @ApiOperation("根据批次查库存")
    @GetMapping(value = "/queryStockProductByBatchNum")
    public AjaxResult queryStockProductByBatchNum(@ApiParam(value = "拆解员", required = true) @RequestParam(value = "dismantler") String dismantler) {
//TODO
//        return success(stockProductService.queryStockProductByBatchNum(id));
        return null;
    }

}
